StupidBeauty
Read times:526Posted at:Sat Jun 30 20:52:42 2012
- no title specified

转载:Qt中执行外部程序介绍 QProcess

使用QProcess::startDetached这个静态函数来启动一个外部进程的话,本进程就无法读取到该外部进程在终端输出的文字内容。因为这种方式启动的进程会成为守护进程,使用ps命令可以看到那个外部进程没有关联到任何的控制台。

http://blog.sina.com.cn/s/blog_7243586a0100t2vn.html

亮点:

QProcess ::startDetached( " a.exe" ,list); 或 QProcess :: execute ( " a.exe" ,list);

第二种方法:创建QProcess类,这种方法的好处是可以查看外部程序返回的数据,输出结果

QProcess *pProces = new QProcess(this);

connect(pProces, SIGNAL (readyRead()),this, SLOT (on_read()));

QStringList list;

pProces->start("a.exe", list);

slot 函数:

void on_read()

{

QProcess *pProces = ( QProcess *)sender();

QString result = pProces->readAll();

QMessageBox::warning(NULL, "", result);

}

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands

 
Recent comments
2017年4月~2019年4月垃圾短信排行榜Posted at:Thu Sep 26 04:51:48 2024
Qt5.7文档翻译:QWebEngineCookieStore类,QWebEngineCookieStore ClassPosted at:Fri Aug 11 06:50:35 2023盲盒kill -9 18289 Grebe.20230517.211749.552.mp4